data modify entity @s item.id set value "sea_lantern"
data modify entity @s item.components."minecraft:custom_data".guardTowerData set from entity @p[tag=placer] SelectedItem.components."minecraft:custom_data".guard_tower
data modify entity @s item.components."minecraft:custom_data".guardTowerData.originPos set from entity @s Pos
data modify entity @s item.components."minecraft:custom_data".guardTowerData.placerPos set from entity @p[tag=placer] Pos
data modify entity @s brightness set value {block:15,sky:3}
data modify entity @s item.components."minecraft:custom_data".guardTowerData.PowerInputEmpty set value true

execute unless data entity @s item.components."minecraft:custom_data".guardTowerData.HP run data modify entity @s item.components."minecraft:custom_data".guardTowerData.HP set from entity @s item.components."minecraft:custom_data".guardTowerData.maxHP

execute store result entity @s item.components."minecraft:custom_data".guardTowerData.HP int 1 run data get entity @s item.components."minecraft:custom_data".guardTowerData.HP

execute if entity @p[tag=placer,team=blue] run tag @s add blue
execute if entity @p[tag=placer,team=blue] run team join blue @s
execute if entity @p[tag=placer,team=red] run tag @s add red
execute if entity @p[tag=placer,team=red] run team join red @s

#Text
data modify entity @s[tag=blue] item.components."minecraft:custom_data".guardTowerData.healthDisplayTextComponent append value {"text":"守卫塔","color":"blue"}
data modify entity @s[tag=red] item.components."minecraft:custom_data".guardTowerData.healthDisplayTextComponent append value {"text":"守卫塔","color":"red"}
data modify entity @s[tag=] item.components."minecraft:custom_data".guardTowerData.healthDisplayTextComponent append value {"text":"守卫塔","color":"light_purple"}
    #Type
    data modify entity @s[nbt={item:{components:{"minecraft:custom_data":{guardTowerData:{type:"E"}}}}}] item.components."minecraft:custom_data".guardTowerData.healthDisplayTextComponent append value {"text":"-E型"}
    data modify entity @s[nbt={item:{components:{"minecraft:custom_data":{guardTowerData:{type:"L"}}}}}] item.components."minecraft:custom_data".guardTowerData.healthDisplayTextComponent append value {"text":"-L型"}

tag @s add guardTower
tag @s add guardTower.entity
tag @s add PowerUsed
tag @s add GameCtrol
tag @s add main